package com.woniuxy.springparking.controller;

import com.woniuxy.springparking.asepct.SysLog;
import com.woniuxy.springparking.common.RestDto;
import com.woniuxy.springparking.common.RestResult;
import com.woniuxy.springparking.service.TPerStallService;
import com.woniuxy.springparking.vo.TPerStallVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TPerStallController {
    @Autowired
    private TPerStallService tPerStallService;

    @GetMapping("/toTPStallByPage")
    @ApiOperation(value = "分页查询所有用户车位信息",httpMethod = "GET",
            protocols = "HTTP",produces = "application/json",
            response = RestResult.class,notes = "分页查询所有用户车位信息")
    public RestResult toTPStallByPage(TPerStallVo tsVo){
        return this.tPerStallService.seletTPByPage(tsVo);
    }

    @DeleteMapping("/delTPStall.do")
    @ApiOperation(value = "按id删除用户车位",httpMethod = "DELETE",
            protocols = "HTTP",produces = "application/json",
            response = RestDto.class,notes = "按id删除用户车位")
    @SysLog(value1 = "删除",value2 = "删除用户车位信息")
    public RestDto delTPStall(Integer perStallId){
        RestDto dto = new RestDto();
        try {
            this.tPerStallService.remove(perStallId);
            dto.setCode(200);
            dto.setMsg("删除成功");
        } catch (Exception e) {
            e.printStackTrace();
            dto.setCode(-1);
            dto.setMsg("删除成功");
        }
        return dto;
    }
}
